dic = {}
print(dic)
dic = {'Alice': '2341', 'Beth': '9102'}
print(dic)
print(len(dic))

dic = dict([('k1', 'val1'), ('k2', 'val2')])
print(dic)

dic = dict(k1='val1', k2='val2', k3='val3')
print(dic)

print(dic['k1'])

# 1  直接遍历字典获取键，根据键取值
for key in dic:
    print(key, dic[key])

# 2  利用items方法获取键值，速度很慢，少用！
for key, value in dic.items():
    print(key, value)

# 3  利用keys方法获取键
for key in dic.keys():
    print(key, dic[key])

# 4  利用values方法获取值，但无法获取对应的键。
for value in dic.values():
    print(value)
